﻿using System;
using System.Collections.Generic;
using System.Text;

using OgilvyOne.UKNow.Common;
using OgilvyOne.UKNow.Model;

namespace OgilvyOne.UKNow.Globalization
{
    public class ChineseLanguage : ILanguage
    {
        public LanguageType LanguageType { get { return LanguageType.cn; } }

        public string GetModelText(Type modelType)
        {
            string typeText = null;

            if (modelType.Equals(typeof(ArtFormModel)))
                typeText = "艺术形式";
            else if (modelType.Equals(typeof(EventsCommentModel)))
                typeText = "活动评论";
            else if (modelType.Equals(typeof(EventsImageModel)))
                typeText = "活动图片";
            else if (modelType.Equals(typeof(EventsInterviewVideoModel)))
                typeText = "活动采访视频";
            else if (modelType.Equals(typeof(EventsModel)))
                typeText = "活动";
            else if (modelType.Equals(typeof(EventsVideoModel)))
                typeText = "活动视频";
            else if (modelType.Equals(typeof(MemberModel)))
                typeText = "会员";
            else if (modelType.Equals(typeof(NewsModel)))
                typeText = "新闻";
            else if (modelType.Equals(typeof(SponsorModel)))
                typeText = "赞助商";
            else if (modelType.Equals(typeof(WarmupCommentModel)))
                typeText = "作品评论";
            else if (modelType.Equals(typeof(WarmupModel)))
                typeText = "作品";
            else if (modelType.Equals(typeof(EventsLogModel)))
                typeText = "活动浏览记录";
            else
                typeText = "未定义的实体类型";
            
            return typeText;
        }

        public string GetActionText(Enums.Action action)
        {
            string text = null;
            switch (action)
            {
                case Enums.Action.Save:
                    text = "保存";
                    break;
                case Enums.Action.Delete:
                    text = "删除";
                    break;
                case Enums.Action.Forward:
                    text = "转发";
                    break;
                case Enums.Action.Publish:
                    text = "发布";
                    break;
                case Enums.Action.UnPublish:
                    text = "撤销";
                    break;
                case Enums.Action.Vote:
                    text = "投票";
                    break;
                case Enums.Action.Register:
                    text = "注册";
                    break;
                case Enums.Action.SignIn:
                    text = "登录";
                    break;
                default:
                    text = "未定义的操作类型";
                    break;
            }

            return text;
        }

        public string GetActionResultText(Enums.ActionResult result)
        {
            string text = null;
            switch (result)
            {
                case Enums.ActionResult.Success:
                    text = "成功";
                    break;
                case Enums.ActionResult.Failure:
                    text = "失败";
                    break;
                case Enums.ActionResult.Exception:
                    text = "发生异常";
                    break;
                default:
                    text = "未定义的操作结果";
                    break;
            }

            return text;
        }

        public string GetAlertMessage(Type modelType, Enums.Action action, Enums.ActionResult result, Exception ex)
        {
            string modelTypeText = GetModelText(modelType);
            string actionText = GetActionText(action);
            string actionResultText = GetActionResultText(result);

            string message = string.Format("{0}{1}{2}.", modelTypeText, actionText, actionResultText);
            if (ex != null)
                message += " 异常信息: " + ex.Message;

            return message;
        }

        public string GetAlertMessage(Type modelType, Enums.Action action, Enums.ActionResult result) 
        {
            return GetAlertMessage(modelType, action, result, null);
        }
    }
}
